/**
 * Create in 2012-4-26.
 */
package kit4j.common.lang;

import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

/**
 * 
 * @author MiniKnife
 *
 */
public abstract class AbstractCalendarTimeUnitStrategy implements TimeUnitStrategy {
	
	private Calendar calendar;

	public AbstractCalendarTimeUnitStrategy() {
		calendar = Calendar.getInstance();
	}

	public AbstractCalendarTimeUnitStrategy(TimeZone zone) {
		calendar = Calendar.getInstance(zone);
	}

	public AbstractCalendarTimeUnitStrategy(Locale locale) {
		calendar = Calendar.getInstance(locale);
	}

	public AbstractCalendarTimeUnitStrategy(TimeZone zone, Locale locale) {
		calendar = Calendar.getInstance(zone, locale);
	}

	/**
	 * @see kit4j.common.lang.TimeUnitStrategy#nextTime(java.util.Date)
	 */
	@Override
	public Date nextTime(Date originTime) {
		calendar.setTime(originTime);
		
		return nextTime(calendar);
	}
	
	abstract protected Date nextTime(Calendar calendar);

}
